package statistics;

import java.util.Random;

/**
 * This is an abstract class, called Distribution. It demands that all
 * of its subclasses implement the methods expectation(), variance() and nextRandom().
 * @version 1.0
 */

public abstract class Distribution implements java.io.Serializable {

  /**
   * This is a random number generator.
   */

  protected Random random;

   /**
    * Returns the expectation of a random variable with this distribution.
    * @return EX
    */
    
    public abstract double expectation();
    
   /**
    * Returns the variance of a random variable with this distribution.
    * @return var X
    */
    
    public abstract double variance();
    
   /**
    * Returns the standard deviation of a random variable with this distribution.
    * @return std.dev X (=sqrt(var X))
    */
    
    public double standardDeviation() {
      return Math.sqrt(variance());
    }

   /**
    * Returns a number generated by a random number generator which has the specified distribution.
    * @return random number
    */

    public abstract double nextRandom();
}
